Conversation
bca3f3e to
d7df55a
Compare
d7df55a to
e21928a
Compare
🔬 Stockfish Benchmark Resultsvs Stockfish Skill Level 3
Non-checkmate endings:
vs Stockfish Skill Level 4
Non-checkmate endings:
vs Stockfish Skill Level 5
Non-checkmate endings:
Configuration
|
Greptile OverviewGreptile SummaryThis PR optimizes the board evaluation performance through three key improvements:
The changes are well-implemented and maintain evaluation correctness. The optimizations reduce computational overhead without altering search behavior. The cache eviction strategy is simple but effective for preventing unbounded memory growth during extended searches. Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| moonfish/psqt.py | Optimized evaluation caching with Zobrist hashing and piece iteration; no logical issues found |
Sequence Diagram
sequenceDiagram
participant Engine as Alpha-Beta Engine
participant Cache as board_evaluation_cache
participant Eval as board_evaluation
participant Board as chess.Board
Engine->>Cache: call board_evaluation(board)
Cache->>Board: zobrist_hash(board)
Board-->>Cache: int hash key
alt Cache hit
Cache-->>Engine: return cached value
else Cache miss
alt Cache full (≥1M entries)
Cache->>Cache: clear entire cache
end
Cache->>Eval: call board_evaluation(board)
Eval->>Eval: get_phase(board)
loop For each piece type
Eval->>Board: pieces(piece_type, WHITE)
Board-->>Eval: SquareSet of white pieces
loop For each white piece
Eval->>Eval: mg_white += table[square^56] + value
Eval->>Eval: eg_white += table[square^56] + value
end
Eval->>Board: pieces(piece_type, BLACK)
Board-->>Eval: SquareSet of black pieces
loop For each black piece
Eval->>Eval: mg_black += table[square] + value
Eval->>Eval: eg_black += table[square] + value
end
end
Eval->>Eval: calculate tapered eval based on phase
Eval-->>Cache: evaluation score
Cache->>Cache: store in cache[hash]
Cache-->>Engine: return evaluation score
end
🔬 Stockfish Benchmark Resultsvs Stockfish Skill Level 3
Non-checkmate endings:
vs Stockfish Skill Level 4
Non-checkmate endings:
vs Stockfish Skill Level 5
Non-checkmate endings:
Configuration
|
🔬 Stockfish Benchmark Resultsvs Stockfish Skill Level 3
Non-checkmate endings:
vs Stockfish Skill Level 4
Non-checkmate endings:
vs Stockfish Skill Level 5
Non-checkmate endings:
Configuration
|
Performance optimizations for board evaluation: - Use Zobrist hash instead of FEN string for cache keys (faster hashing) - Add cache size limit (1M entries) to prevent unbounded memory growth - Optimize board_evaluation() to iterate over pieces instead of all 64 squares - Typically 16-32 pieces vs always 64 squares - Reduces unnecessary iterations by ~50-75% These changes improve evaluation speed without affecting correctness. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The cache adds complexity without significant benefit for typical game sessions (10k-100k unique positions). Removes the dictionary, decorator, and unused imports.
42e6fc1 to
6c5f8af
Compare
|
/run-nps-benchmark |
⚡ NPS Benchmark Results
Per-position breakdown |
Summary
board_evaluation()to iterate over actual pieces (~16-32) instead of all 64 squaresDetails
The board evaluation function is called frequently during search. These optimizations reduce overhead:
chess.polyglot.zobrist_hash()returns an integer, which is faster to hash and compare than FEN stringsboard.pieces(piece_type, color)returns only occupied squares, reducing iterations by 50-75%Test plan
🤖 Generated with Claude Code